//
//  BaseTabBarController.m
//  TruckUser
//
//  Created by Ting Han on 2017/10/16.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import "BaseTabBarController.h"
#import "HTMineViewController.h"
#import "HTFindGoodsViewController.h"
#import "HTFindTruckViewController.h"
#import "HTDeliverGoodsViewController.h"
#import "BaseNavigationController.h"

@interface BaseTabBarController ()

@property (nonatomic,strong) HTDeliverGoodsViewController *deliverVC;
@property (nonatomic,strong) HTFindGoodsViewController *findGoodsVC;
@property (nonatomic,strong) HTFindTruckViewController *findTruckVC;
@property (nonatomic,strong) HTMineViewController *mineVC;


@end

@implementation BaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpAllChildViewController];
    self.selectedIndex = 0;
    
}
- (void)setUpAllChildViewController{
    self.deliverVC = [[HTDeliverGoodsViewController alloc]init];
    [self setUpOneChildViewController:self.deliverVC image:[UIImage imageNamed:@"tab_deliver"] selectedImage:[UIImage imageNamed:@"tab_deliver_sel"] title:@"发货"];
    self.findGoodsVC = [[HTFindGoodsViewController alloc]init];
    [self setUpOneChildViewController:self.findGoodsVC image:[UIImage imageNamed:@"tab_findGoods"] selectedImage:[UIImage imageNamed:@"tab_findGoods_sel"] title:@"找货"];
    self.findTruckVC = [[HTFindTruckViewController alloc]init];
    [self setUpOneChildViewController:self.findTruckVC image:[UIImage imageNamed:@"tab_findTruck"] selectedImage:[UIImage imageNamed:@"tab_findTruck_sel"] title:@"找车"];
    self.mineVC = [[HTMineViewController alloc]init];
    [self setUpOneChildViewController:self.mineVC image:[UIImage imageNamed:@"tab_mine"] selectedImage:[UIImage imageNamed:@"tab_mine_sel"] title:@"我的"];
}

- (void)setUpOneChildViewController:(UIViewController *)vc image:(UIImage *)image selectedImage:(UIImage *)selectedImage title:(NSString *)title
{
    vc.title = title;
    BaseNavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:vc];
    nav.tabBarItem.image = image;
    nav.tabBarItem.selectedImage = selectedImage;
    //设置选中时字体的颜色
    self.tabBar.tintColor = kBlueColor;
//    [nav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:kNaviBarColor} forState:UIControlStateSelected];
    [self addChildViewController:nav];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
